package thread;

public class SleepDemo2 {
    public static void main(String[] args) {
        Thread zf = new Thread("张飞"){
            @Override
            public void run() {
                System.out.println(getName()+":二哥我没钱吃饭了，我睡会觉");
                try {
                    Thread.sleep(1000000);
                } catch (InterruptedException e) {
                    System.out.println(getName()+":我他妈没钱吃饭肚子饿的不行了，你还让我去搬砖！");;
                }
                System.out.println(getName()+":有钱了马上去搬砖");
            }
        };
        Thread gy = new Thread("关羽"){
            @Override
            public void run() {
                System.out.println(getName()+":二弟什么时候来我工地上搬砖");
                for (int i=0;i<5;i++){
                    System.out.println(getName()+":快来搬砖！");
                    try {
                        Thread.sleep(1500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println(getName()+":好累！");
                System.out.println(getName()+":我来找你搬砖了");
                zf.interrupt();
            }
        };
        zf.start();
        gy.start();
    }
}
